using Microsoft.EntityFrameworkCore.Design;

namespace CampusModel;

using Model;
using Microsoft.EntityFrameworkCore;

public class CampusModelDbContext(DbContextOptions<CampusModelDbContext> options) : DbContext(options)
{
    public DbSet<Teacher> Teachers { get; set; }
    public DbSet<Student> Students { get; set; }
    public DbSet<Course> Courses { get; set; }
    public DbSet<AttendanceRecord> AttendanceRecords { get; set; }
    public DbSet<User> Users { get; set; }
    public DbSet<Class> Classes { get; set; }
    public DbSet<Admin> Admins { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
    }
}

public class ActivityDbContextDesignTimeFactory : IDesignTimeDbContextFactory<CampusModelDbContext>
{
    public CampusModelDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<CampusModelDbContext>();
        optionsBuilder.UseSqlServer("server=127.0.0.1,1433;database=CampusSystemDatabase;User ID=sa;Password=Aa123456789@;Trusted_Connection=false;Encrypt=False");
        return new CampusModelDbContext(optionsBuilder.Options);
    }
}